﻿using System;
using System.Collections.Generic;
using System.Text;
using Fcdbas.Core.WCF.TransFile.Contracts.Services;
using Fcdbas.Core.WCF.TransFile.Contracts.Enums;
using Fcdbas.Core.WCF.TransFile.Contracts.Models;
using Fcdbas.Core.WCF.TransFile.Service.Working;

namespace Fcdbas.Core.WCF.TransFile.Service.Services
{

    ///<summary>
    ///作者:   谢海波
    ///时间:   2011-09-15
    ///描述:   国泰安文件传输服务
    ///<summary>
    public class FileService:IFileService 
    {
        /// <summary>
        /// 尝试连接服务器
        /// </summary>
        /// <returns>是否连接成功</returns>
        public bool TryConnection()
        {
            return true;
        }

        #region ====================================  验证 ====================================

        public CheckFileResult CheckFile(LoadFileInfoModel info)
        {
            LoadFileWorker worker = new LoadFileWorker(info);
            return worker.CheckFile();
        }

        public TransFilesResult CheckFileOnServer(TransFilesOnServerModel item)
        {
            LoadFileWorker workerItem = new LoadFileWorker();
            return workerItem.CheckFile(item);
        }

        #endregion


        #region ====================================  偏移量 ====================================

        public GetOffSetResult GetFileOffSet(LoadFileInfoModel info, bool createNew)
        {
            LoadFileWorker worker = new LoadFileWorker(info);
            return worker.GetFileOffSet(createNew);
        }

        public long GetDownLoadFileSize(SpaceType loadSpaceType, string customFolder, List<string> relativePaths)
        {
            LoadFileWorker worker = new LoadFileWorker();
            return worker.GetDownLoadSize(loadSpaceType, customFolder, relativePaths);
        }


        #endregion


        #region ====================================  上传 ====================================

        public LoadFileInfoModel UpLoadFile(LoadFileInfoModel info)
        {
            LoadFileWorker worker = new LoadFileWorker(info);
            return worker.UpLoad();
        }

        #endregion


        #region ====================================  下载 ====================================

        public LoadFileInfoModel DownLoadFile(LoadFileInfoModel info)
        {
            LoadFileWorker worker = new LoadFileWorker(info);
            return worker.DownLoad();
        }

        #endregion


        #region ====================================  移除 ====================================

        public CheckFileResult DeleteFile(LoadFileInfoModel info)
        {
            LoadFileWorker worker = new LoadFileWorker(info);
            return worker.DeleteFile();
        }

        #endregion


        #region ====================================  移动 ====================================

        public TransFilesResult TransFilesMove(TransFilesOnServerModel item)
        {
            LoadFileWorker workerItem = new LoadFileWorker();
            return workerItem.MoveFile(item);
        }

        #endregion


        #region ====================================  复制 ====================================

        public TransFilesResult TransFilesCopy(TransFilesOnServerModel item)
        {
            LoadFileWorker workerItem = new LoadFileWorker();
            return workerItem.CopyFile(item);
        }

        #endregion
    }
}
